import React, { Component, ComponentClass } from 'react';
import Taro from '@tarojs/taro';
import Skeleton from 'taro-skeleton'
import {ScrollView, View, Text, Block, Checkbox, Navigator, Button, Image} from '@tarojs/components'
import {AtFloatLayout, AtIcon, AtForm, AtInput, AtModalContent, AtModal, AtSwitch, AtInputNumber} from 'taro-ui'
import {
  GET_DEFAULT_INFO,
  GROUP_GETGOODS,
  GROUP_GOODSLIST,
  GROUP_CREATE,
  GROUP_PAYTOKEN,
  GROUP_PAY,
  LIST_PRO_DAY_INFO,
  H5_ORDER_PAY,
  GROUP_GET_LINKINFO,
  RESOURCE_URL,
  GROUP_DEL_CREATE,
  GET_PHONE,
  PC_QRCODE,
  PC_ORDER_STATUS,
  TRANS_ORDER_DETAIL,
  CREATE_AND_PAY, TARO_ENV
} from '../../constants/api'
import './combination.scss'
import {PlatformSet, CalendarInfo} from '../../utils/server.interface'
import Calendar from '../components/calendar/calendar';
import {getHeadTop, toIosDateFormat, getTempSellerId, clearSearch} from "../../utils/tools";
import {platform} from "../../utils/platform-settting.service";
import NumberInput from "../components/number-input/number-input";
import {http} from "../../utils/http";
import {user} from "../../utils/user.service";
import {newHttp} from "../../utils/request";
import {payment} from "../../utils/payment.service";
import {h5Wx} from "../../utils/h5.service";
import GzhAuth from "../../components/gzh-auth/gzh-auth"
import {getContent} from "../../utils/handlerPublicCode";

type PageStateProps = {
  // location: CityLocation
}
type PageDispatchProps = {}
type PageOwnProps = {}
type PageState = {
  isDaypartingAppointment: boolean
  defaultDate: boolean
  bottomView: any
  configArr: any
  openTraveler: boolean
  commonValidDate: string
  openKD: boolean // 蝌蚪币的开关
  goodsDiscountCodeType?: any
  force_platform_seller?: any
  goodsDiscountCodeId?: any
  fromOrderNum?: any
  fromGoodDetail?: any
  fristShow: boolean
  showCalendar: boolean
  calendarInfo: CalendarInfo[]
  jf: number
  goodDetail: any
  useIntegral: boolean
  paySuccessShow: boolean
  category: number
  orderDate: string
  isCarry: boolean
  itemH: number
  isClickDate: boolean
  week: any
  resetBalance: boolean
  userBalance: boolean
  showLoading: boolean
  platformSet: PlatformSet | false
  isRule: boolean
  index: number | string
  disabled: boolean
  layoutIndex: number
  ldx: number
  tabIndex: number
  noticeShow: boolean
  curTabIndex: number
  orderList: any
  orderListDan: any
  main: any
  searchKey: string
  searchBarTop: number
  floatLayout: boolean
  notice: string
  detailShow: boolean
  floatLayoutIdcard: boolean
  floatLayoutCalendar: boolean
  lookMoreShow: boolean
  currentDate: any
  minDate: string
  maxDate: string
  threeDate: any
  totalPrice: number
  contactDataAry: []
  oldFirstIndex: number | string
  oldCtIndex: number | string
  idcardDel: string
  idcardDelIndex: string
  contactData: any
  travelDate: string
  itemId: string
  mainUuid: string
  goodsGroup: {
    goods_id: string
    num: string
    name: string
  }[]
  paytoken: any
  userOk: number
  payData: {
    consume_fee: Number
    orderNum: string
    payToken: string
    custom_item_detail: string
    useAccountPay: number
    phone: string
    linkman: string
    identity_num: string
    remark: string
    creditPay: number
    isSaveLinkInfo: string
    custom_item_key: string
    face: string
  }
  orderNo: string
  opentips: boolean
  oldRectHeight: number
  opentipsIdnex: number
  tempSellerId: string
  pcQrcodeShow: boolean
  pcqrcode: string
  env: string
}
type IProps = PageStateProps & PageDispatchProps & PageOwnProps

interface Combination {
  props: IProps
}

class Combination extends Component {
  tabList = [{title: '全部', value: -1}, {title: '待付款', value: 0}, {title: '待使用', value: 55}, {title: '已完成', value: 66}]
  state: PageState = {
    isDaypartingAppointment: false, // 是否为免费入园的分时预约
    defaultDate: true, // 默认选中时间，true：默认，false: 不默认
    configArr: [],
    bottomView: '',
    openTraveler: true, // 所有的姓名手机号是否全部打开
    commonValidDate: '',
    openKD: true,
    fromOrderNum: null,
    fromGoodDetail: null,
    fristShow: false,
    showCalendar: false,
    calendarInfo: [],
    goodDetail: [],
    jf: 0,
    useIntegral: false,
    category: 1,
    orderDate: '',
    isCarry: true,
    itemH: 0,
    isClickDate: true,
    week: ['周天', '周一', '周二', '周三', '周四', '周五', '周六'],
    resetBalance: false,
    userBalance: false,
    showLoading: true,
    platformSet: false,
    isRule: false,
    index: '',
    layoutIndex: 0,
    idx: 0,
    disabled: true,
    tabIndex: 0,
    noticeShow: true,
    paySuccessShow: false,
    curTabIndex: 0,
    orderList: [],
    orderListDan: [],
    main: {},
    searchKey: '',
    searchBarTop: 0,
    floatLayout: false,
    notice: '',
    detailShow: false,
    floatLayoutIdcard: false,
    floatLayoutCalendar: false,
    lookMoreShow: false,
    currentDate: {},
    minDate: this.GetDateStr(0),
    maxDate: this.GetDateStr(30),
    threeDate: [],
    travelDate: '',
    totalPrice: 0,
    contactDataAry: [],
    contactData: [],
    idcardDel: '',
    idcardDelIndex: '',
    oldFirstIndex: '',
    oldCtIndex: '',
    itemId: '',
    mainUuid: '',
    goodsGroup: [],
    orderNo: '',
    paytoken: [],
    userOk: 1,
    payData: {
      consume_fee: 0.00,
      orderNum: '',
      payToken: '',
      custom_item_detail: '',
      useAccountPay: 0,
      phone: '',
      linkman: '',
      identity_num: '',
      remark: '',
      creditPay: 0,
      isSaveLinkInfo: '',
      custom_item_key: '',
      face: ''
    },
    opentips: false,
    oldRectHeight: 0,
    opentipsIdnex: 999,
    tempSellerId: '',
    pcQrcodeShow: false,
    pcqrcode: '',
    env: '',
    force_platform_seller: '',
    goodsDiscountCodeType: '',
    goodsDiscountCodeId: ''
  }

  siteHash = ''
  params = Taro.getCurrentInstance().router.params

  async UNSAFE_componentWillMount() {
    if (process.env.TARO_ENV === 'h5') {
      await h5Wx.getConfig()
      const extConfig = Taro.getStorageSync('user');
      this.siteHash = extConfig.pkey || '';
    } else {
      const extConfig = Taro.getExtConfigSync();
      this.siteHash = extConfig['p-key'] || '';
    }
    const tempSellerId = getTempSellerId(this)
    if (this.params.isDaypartingAppointment) {
      this.setState({isDaypartingAppointment: true});
    } else {
      this.setState({isDaypartingAppointment: false});
    }
    this.setState({
      goodsDiscountCodeType: this.params.goodsDiscountCodeType || '',
      goodsDiscountCodeId: this.params.goodsDiscountCodeId || '',
      force_platform_seller: this.params.force_platform_seller || '',
      fromOrderNum: this.params.fromOrderNum,
      itemId: this.params.itemId,
      mainUuid: this.params.uuid,
      env: this.params.env,
      type: this.params.type,
      category: this.params.category,
      tempSellerId,
      minDate: this.GetDateStr(0),
      maxDate: this.GetDateStr(30),
    }, () => {
      this.getData('', this.params.type)
    })
    const headTop = getHeadTop()
    const searchBarTop = headTop.statusBar > 20 ? (headTop.statusBar + headTop.top + 40) : (headTop.statusBar + headTop.top + 50)
    const platformSet = await platform.getSetting()
    if (platformSet.is_order_default_check_date && platformSet.is_order_default_check_date == 1) {
      this.setState({defaultDate: false})
    } else {
      this.setState({defaultDate: true})
    }
    // if (!platformSet.is_order_default_check_daten || platformSet.is_order_default_check_daten == 1) {
    //   this.setState({defaultDate: false})
    // } else {
    //   this.setState({defaultDate: true})
    // }
    if (platformSet.platformName) {
      Taro.setNavigationBarTitle({
        title: platformSet.platformName
      })
    }
    this.setState({platformSet, isRule: !!platformSet.user_agreement_type})
    await user.checkLogin()
    // 获取产品详情
    this.setState({
      searchBarTop
    })
  }

  async componentDidShow() {
    clearSearch()
    const {orderList, resetBalance, fromGoodDetail} = this.state
    this.setState({
      env: this.params.env,
    })
    if (orderList.length > 0) {
      await this.linkData(orderList)
      this.updateContact()
    }
    if (resetBalance && !fromGoodDetail) {
      // 获取支付凭证
      const res = await this.getPaytoken()
      // 如果有这个支付凭证就resetBalance为false
      if (res) {
        this.setState({resetBalance: false})
      }
    }
  }

  async initCalendatData(goodDetail = this.state.goodDetail) {
    const calendarInfo = await newHttp.catchPost<CalendarInfo[]>(LIST_PRO_DAY_INFO, {
      uuid: goodDetail.main.uuid,
      category: this.state.category,
    })
    if (calendarInfo && calendarInfo.length > 0) {
      const data = await this.ckeckStock(calendarInfo)
      const firstDay = data.date
      if (new Date(toIosDateFormat(firstDay)).getTime() > new Date(toIosDateFormat(this.state.travelDate)).getTime()) {
        const good = calendarInfo.find(item => item.date === this.state.travelDate)
        const that = this
        if (!good || !good.surplus_stock) {
          this.setState({
            buyDate: {
              start: data.date,
              end: this.calcTomorrow(data.date)
            }
          }, async () => {
            const feeInfo = await that.getPaytoken()
            that.setState({feeInfo, getFee, fristShow: true}, () => {
              if (goodDetail.goods.category !== 4) {
                that.integralChangebtn(feeInfo.maxJf)
              }
              if (goodDetail.goods.is_open != 0) {
                that.showCalendar()
              }
            })
          })
        }
      }
      this.setState({calendarInfo})
    } else {
      Taro.showModal({
        title: '提示',
        content: '当前产品没有可购买日期，点击返回上一页',
        success: function (res) {
          if (res.confirm) {
            Taro.navigateBack()
          }
        },
        showCancel: false
      })
    }
  }

  async ckeckStock(data) {
    for (let i = 0; i < data.length; i++) {
      if (data[i].surplus_stock) {
        return data[i]
        break
      }
    }
  }

  setStateSync(state) {
    return new Promise(resolve => {
      this.setState(state, resolve);
    });
  }

  async calendarSelect(value: { start: string; end: string; type: string; single: string; range: string[] }) {
    if (value.type === 'range') {
      await this.setStateSync({
        floatLayoutCalendar: false,
        travelDate: value.single,
        buyDate: {start: value.start || '', end: value.end}
      });
    } else {
      await this.setStateSync({
        floatLayoutCalendar: false,
        travelDate: value.single,
        buyDate: {start: value.single || ''}
      });
    }
    const day = new Date(value.single).getDay()
    const _threeDate = this.state.threeDate
    const dateAry = value.single.split('-')
    if (value.single != _threeDate[0].date && value.single != _threeDate[1].date) {
      _threeDate[2].showDate = dateAry[1] + '-' + dateAry[2]
      _threeDate[2].date = value.single
      _threeDate[2].week_str = this.state.week[day]
      _threeDate[2].status = 1
    }
    this.setState({threeDate: _threeDate, defaultDate: true})
    this.getData(value.single, 'date')
  }

  // 获取产品详情
  async getData(date = '', typeName) {
    // 产品详情
    const {type, itemId, uuid, fromOrderNum} = this.params
    const {travelDate} = this.state
    this.setState({goodsGroup: [], lookMoreShow: false, isClickDate: false, typeName, showLoading: false})
    let _type = type
    if (typeName == 'date') {
      _type = 'date'
    }
    if (this.state.orderNo) this.delOrder()
    const list = await http.carGet(_type == 'good' ? GROUP_GETGOODS : GROUP_GOODSLIST, {
      uuid: _type == 'date' ? uuid : itemId,
      category: this.state.category,
      date: travelDate
    })
    const singleChoiceId = this.params.singleChoiceId || ''
    if (singleChoiceId && list.goodsList) {
      for (let i = 0; i < list.goodsList.length; i++) {
        if (list.goodsList[i].id != singleChoiceId) {
          list.goodsList[i].num = 0
        }
      }
    }
    let userOk = 1
    if (process.env.TARO_ENV === 'tt') {
      // 检查用户有没有授权头像手机号
      userOk = await user.checkUserInfo()
      if (userOk == 2) {
        Taro.login().then(async code => {
          user.code = code.code
          const ret = await user.doLogin({
            nickName: '',
            gender: 1,
            language: '',
            city: '',
            province: '',
            country: '',
            avatarUrl: '',
            bindSellerId: 0,
            itemUUID: '',
            path: ''
          })
          if (!ret) {
            Taro.showToast({
              title: '授权失败,请退出小程序重试',
              icon: 'none'
            })
            return
          }
        })
      }
    }
    let fromGoodDetail = null
    if (fromOrderNum) {
      fromGoodDetail = await http.postCar(TRANS_ORDER_DETAIL + fromOrderNum, {})
      const custom_item_detail = JSON.parse(fromGoodDetail.custom_item_detail)
      fromGoodDetail.custom_item_config = JSON.stringify(custom_item_detail.custom_item_config)
      const paytoken = {total_fee: fromGoodDetail.trans_price}
      this.setState({fromGoodDetail, paytoken})
    }
    // Taro.hideLoading()
    if (list) {
      if (fromGoodDetail) {
        list.goodsList.map((item, index) => {
          if (item.id !== fromGoodDetail.goods_id) {
            list.goodsList.splice(index, 1)
          } else {
            list.goodsList[index].num = fromGoodDetail.buy_amount
          }
        })
      }
      let orderListDan = []
      this.linkData(fromGoodDetail ? [fromGoodDetail] : list.goodsList, list.main, fromGoodDetail)
      if (list.main.is_single_tourist && !fromGoodDetail) {
        orderListDan = orderListDan.push(list.goodsList[0])
      }
      // 日期处理
      if (!this.state.travelDate) {
        const ThreeDayCalendar = list.ThreeDayCalendar
        for (const i in list.ThreeDayCalendar) {
          const showDate = list.ThreeDayCalendar[i].date.split('-')
          ThreeDayCalendar[i].showDate = showDate[1] + '-' + showDate[2]
        }
        this.setState({
          threeDate: ThreeDayCalendar,
          travelDate: ThreeDayCalendar[0].date,
        })
      }
      let commonValidDate = ''
      if (list.main && list.main.common_valid_date) {
        if(list.main.common_valid_date && list.main.common_valid_date.indexOf("(") > -1 && list.main.common_valid_date.indexOf(")") > -1){
          const a1 =/\((.+?)\)/g
          const a2 = list.main.common_valid_date.match(a1).toString()
          commonValidDate = a2.replace("(","")
          commonValidDate = commonValidDate.replace(")","")
        } else {
          commonValidDate = ''
        }
      }
      this.setState({
        commonValidDate,
        goodDetail: list,
        orderList: list.goodsList,
        orderDate: travelDate,
        orderListDan,
        main: list.main,
        disabled: false,
        userOk,
        showLoading: false,
        useIntegral: list.main.is_auto_use_integral == 1 ? true : false,
      }, () => {
        if (!this.state.travelDate) {
        }
        if (!fromGoodDetail) {
          this.createOrder()
        }
        this.initCalendatData(this.state.goodDetail)
        this.getSelectorQuery()
      })
    } else {
      Taro.hideLoading()
      this.setState({orderList: [], userOk, isClickDate: true, showLoading: false})
    }
  }

// 获取联系人姓名手机号
  async getLinkAuto() {
    const {payData, contactData} = this.state
    // contactData: 联系人，几乎是返回的列表人信息
    // 如果是老用户，有联系人信息的，支付联系人就取这里的
    // 如果是新用户, 就取联系人的contactData[0][0]['value'][0]
    const data = await http.carGet(GET_DEFAULT_INFO)
    if (data.name && data.phone) {
      payData.linkman = data.name
      payData.phone = data.phone
    } else {
      payData.linkman = contactData[0][0]['value'][0]['name']
      payData.phone = contactData[0][0]['value'][0]['phone']
    }
    this.setState(payData)
  }

  // 更新出行人
  async updateContact() {
    const {orderList, contactData, payData, fromGoodDetail} = this.state
    const _contactData = []
    for (const k in orderList) {
      const config = []
      const custom_item_config = fromGoodDetail ? JSON.parse(fromGoodDetail.custom_item_config) : JSON.parse(orderList[k].custom_item_config)
      for (const k in custom_item_config) {
        if (custom_item_config[k]) config.push(k)
      }
      let list = await http.carGet(GROUP_GET_LINKINFO, {
        config,
        goodsId: fromGoodDetail ? fromGoodDetail.goods_id : orderList[k].id
      })
      if (list && list.length === 0 && custom_item_config['name'] === false && custom_item_config['phone'] === false) {
        list = [{"id":'',
          "uuid":"",
          "value":JSON.stringify([
            {"address":"",
              "comments":"",
              "city":"",
              "num":1,
              "upload_file":[],
              "face":"",
              "province":"",
              "phone":"13700000000",
              "idcard":"",
              "name":"-",
              "checked":true,
              "region":"",
              "mark":""
            }
          ]),
          "field":"name,phone"
        }]
      }
      for (const i in list) {
        list[i].value = JSON.parse(list[i].value)
        if (contactData[k].length === 0) {
          contactData[k].push({field: '', uuid: '', value: [{}]})
        }
        list[i].value[0]['num'] = contactData[k][0].value[0]['num']
        list[i].value[0]['checked'] = !!(contactData[k][i] && contactData[k][i].value[0]['checked']);
        if (custom_item_config['name'] === false && custom_item_config['phone'] === false) {
          list[k].value[0]['checked']  = true
          list[k].value[0]['num'] = 1
        }
      }
      _contactData.push(list)
    }
    const strContactData = JSON.stringify(_contactData)
    let bottomView = ''
    if (Taro.getStorageSync('addContact')) {
      Taro.removeStorageSync('addContact')
      bottomView = 'bottomView0'
    }
    this.setState({contactData: JSON.parse(strContactData), payData, bottomView}, () => {
      this.getLinkAuto()
    })
  }

  // 组织出行人数据
  async linkData(list, main?, fromGoodDetail?) {
    // this.setState({contactData:[]})
    const _contactData = []
    const chenkArr = []
    const listData = list // list: orderList订单列表，代表几个单品
    let {configArr, openTraveler} = this.state
    // 多游客
    for (const i in listData) {
      const config = [] // 游客信息配置为true的字段
      chenkArr.push([])
      const custom_item_config = JSON.parse(listData[i].custom_item_config) // custom_item_config: 游客信息的配置
      for (const k in custom_item_config) {
        if (custom_item_config[k]) config.push(k)
        configArr.push(custom_item_config[k])
      }
      const newArr = []
      for (const k in configArr) {
        if (configArr[k]) {
          newArr.push(configArr[k])
        }
      }
      openTraveler = newArr.length > 0;
      this.setState({configArr})

      // 获取联系人的信息，根据每一个产品的config配置字段
      let list = await http.carGet(GROUP_GET_LINKINFO, {
        config,
        goodsId: fromGoodDetail ? fromGoodDetail.goods_id : listData[i].id
      })
      if (list && list.length === 0 && custom_item_config['name'] === false && custom_item_config['phone'] === false) {
        list = [{"id":'',
          "uuid":"",
          "value":JSON.stringify([
            {"address":"",
              "comments":"",
              "city":"",
              "num":1,
              "upload_file":[],
              "face":"",
              "province":"",
              "phone":"13700000000",
              "idcard":"",
              "name":"-",
              "checked":true,
              "region":"",
              "mark":""
            }
          ]),
          "field":"name,phone"
        }]
      }
      // list出行人列表
      for (const k in list) {
        JSON.stringify(list[k].value)
        list[k].value = JSON.parse(list[k].value)
        list[k].value[0]['checked'] = false
        list[0].value[0]['num'] = 0
        chenkArr[i].push('false')
        if (custom_item_config['name'] === false && custom_item_config['phone'] === false) {
          list[k].value[0]['checked']  = false
          list[k].value[0]['num'] = 1
        }
      }
      // 联系人信息第一次存值，值：数组，list内容
      _contactData.push(list)
    }
    if (_contactData && _contactData[0].length > 0) {
      _contactData[0][0]['value'][0]['num'] = 1
      Taro.setStorageSync('chenkArr', chenkArr)
      // 默认联系人第一个是选中的状态
      _contactData[0][0]['value'][0]['checked'] = true
    }
    const strContactData = JSON.stringify(_contactData)
    // 最后的联系人值
    this.setState({contactData: JSON.parse(strContactData), openTraveler}, () => {
      this.getLinkAuto()
    })
  }

  // 出行人是否展示
  isShowOpenTravel(list) {
    const custom_item_config = JSON.parse(list.custom_item_config)
    const newArr = []
    for (const k in custom_item_config) {
      if (custom_item_config[k]) {
        newArr.push(custom_item_config[k])
      }
    }
    if (newArr.length > 0) {
      return true // 判断是否全部打开，全部关闭出行人就不显示了
    } else {
      return false
    }
  }

  // 删除无效订单
  async delOrder() {
    await newHttp.catchGet(GROUP_DEL_CREATE + this.state.orderNo)
  }

  // 创建订单
  async createOrder() {
    const {orderList, payData} = this.state
    const goodsGroup = []
    // 组织goodsGroup数据
    orderList.map(item => {
      goodsGroup.push({goods_id: item.id, num: item.num, name: item.name})
    })
    const tempSellerId = getTempSellerId(this)
    const data = process.env.P_ENV === 'lx' ?
      await newHttp.catchPost_lxMerge(GROUP_CREATE, {
        tempSellerId,
        goodsGroup: JSON.stringify(goodsGroup)
      })
      :
      await newHttp.catchPost(GROUP_CREATE, {
        tempSellerId,
        goodsGroup: JSON.stringify(goodsGroup)
      });
    if (data) {
      payData.orderNum = data.orderNo
      this.setState({orderNo: data.orderNo, payData}, () => {
        this.setState({goodsGroup})
        // 获取支付凭证
        this.getPaytoken(goodsGroup)
      })
    } else {
      Taro.hideLoading()
    }
  }

  // 获取支付凭证
  async getPaytoken(goodsGroup = this.state.goodsGroup, idx = 0, isShowToast = true) {
    this.setState({isCarry: true})
    const that = this
    const {travelDate, payData, orderList} = this.state
    const tempSellerId = getTempSellerId(this)

    const paytoken = await newHttp.catchPost(GROUP_PAYTOKEN + this.state.orderNo, {
      consume_fee: payData.consume_fee,
      goodsGroup: JSON.stringify(goodsGroup),
      jf: this.state.jf,
      useIntegral: this.state.useIntegral,
      buyDate: travelDate,
      goodsDiscountCodeType: this.state.goodsDiscountCodeType,
      goodsDiscountCodeId: this.state.goodsDiscountCodeId,
      force_platform_seller: this.state.force_platform_seller,
      tempSellerId,
      referSellerId: Taro.getStorageSync('bindSellerId') || 0
    }, true)
    Taro.hideLoading()
    if (paytoken && paytoken.data && paytoken.data.status == 99) {
      Taro.showToast({
        title: paytoken.data.message,
        icon: 'none',
      });
      that.state.paytoken.total_fee = '0.00'
      that.setState({paytoken: that.state.paytoken, isCarry: false})
      return
    }
    if (paytoken) {
      payData['payToken'] = JSON.stringify(paytoken['payToken'])
      for (const k in paytoken['stock']) {
        orderList.map(item => {
          if (item.id == k) {
            item.surplus_stock = paytoken['stock'][k]
          }
        })
      }
      this.setState({paytoken, payData, isClickDate: true, orderList, isCarry: false})
      if (isShowToast) Taro.hideLoading()
      return paytoken
    } else {
      if (isShowToast) Taro.hideLoading()
      this.setState({isClickDate: true, isCarry: false}, () => {
      })
      return false
    }

  }

  submitCheck() {
    const {paytoken, orderList, contactData, payData, main, isRule, fromGoodDetail, defaultDate, goodsGroup} = this.state
    let goodsNum: number = 0
    if (goodsGroup && goodsGroup.length > 0) {
      for (let i=0; i<goodsGroup.length; i++) {
        goodsNum += Number(goodsGroup[i].num)
      }
    }
    if (!defaultDate && main.travel_date_style !== 1) {
      Taro.showToast({title: '请选择出行日期', icon: 'none'})
      return false
    }
    if (goodsNum <= 0 ) {
      Taro.showToast({title: '至少选择一种商品', icon: 'none'})
      return false
    }
    if (!main.is_single_tourist) {
      for (const k in orderList) {
        if (orderList[k].num > 0) {
          const custom_item_config = JSON.parse(orderList[k].custom_item_config)
          for (const v in custom_item_config) {
            if (custom_item_config[v] === true && !contactData[k][0]['value'][0][v]) {
              Taro.showToast({title: `请完善${orderList[k].name}出行人信息`, icon: "none"})
              return
            }
          }
          if (custom_item_config.name === true || custom_item_config.phone === true) {
            if (orderList[k].is_custom_item != 2) {
              if (contactData[k].length < 1 || contactData[k][0]['value'][0]['num'] < 1 || !contactData[k][0]['value'][0]['num']) {
                Taro.showToast({title: `${orderList[k].name}至少添加1位出行人`, icon: "none"})
                return false
              }
            } else {
              // 没有出行人选项
              if (contactData[k].length < 1) {
                Taro.showToast({title: `${orderList[k].name}还需添加1位出行人`, icon: "none"})
                return false
              }
              // 有出行人选项
              if ((orderList[k].num > contactData[k][0]['value'][0]['num']) || !contactData[k][0]['value'][0]['num']) {
                Taro.showToast({
                  title: `${orderList[k].name}还需添加${orderList[k].num - contactData[k][0]['value'][0]['num']}位出行人`,
                  icon: "none"
                })
                return false
              }
            }
          }
        }
      }
    } else {
      const personNum = contactData.filter(item => item.length > 0);
      if(personNum.length === 0) {
        Taro.showToast({title: `还需添加1位出行人`, icon: "none"})
        return false
      }
      const arr = contactData[0].filter(item => {
        return item['value'][0]['checked']
      })
      if (arr.length == 0) {
        Taro.showToast({title: `请选择1位出行人`, icon: "none"})
        return false
      }
      for (const k in orderList) {
        if (orderList[k].num > 0) {
          const custom_item_config = JSON.parse(orderList[k].custom_item_config)
          for (const v in custom_item_config) {
            if (custom_item_config[v] === true && !contactData[k][0]['value'][0][v]) {
              Taro.showToast({title: `请完善${orderList[k].name}出行人信息`, icon: "none"})
              return
            }
          }
        }
      }
    }
    if (!isRule) {
      Taro.showToast({title: '请阅读并同意服务条款', icon: "none"})
      return
    }
    if (!payData.linkman && !main.is_single_tourist) {
      Taro.showToast({title: '请输入联系人姓名', icon: "none"})
      return
    }
    if (!payData.phone) {
      Taro.showToast({title: '请输入联系人手机号', icon: "none"})
      return
    }
    if (paytoken.total_fee == '0.00') {
      this.groupPay(6666)
      return
    }
    if (fromGoodDetail) {
      this.groupPay(9999)
      return
    }
    if (process.env.P_ENV === 'lx') {
      if (paytoken.creditAmount) {
        this.setState({userBalance: true})
      } else {
        this.groupPay(0)
      }
      return false
    }
    // 是否可以余额或授信支付
    if (process.env.P_ENV === 'kd' && paytoken.userCoinBalance >= paytoken.total_fee) {
      return this.setState({userBalance: true})
    }
    if (paytoken.userBalance == 0 && !paytoken.creditAmount) {
      this.groupPay(0)
    } else {
      this.setState({userBalance: true})
    }
  }

  handleClose() {
    this.setState({userBalance: false})
  }

  paySuccess(id?: any) {
    const env = this.params.env;
    if (env == 'pc') {
      this.setState({
        paySuccessShow: true
      });
    } else {
      Taro.redirectTo({url: '/main/order/success?pay=' + id});
    }
  }

  // 订单支付
  async groupPay(status) {
    this.setState({disabled: true})
    const that = this
    const customDetail = {}
    const {orderList, contactData, payData, main, orderNo, paytoken, fromOrderNum} = this.state
    for (const i in orderList) {
      customDetail[orderList[i].id] = {}
      customDetail[orderList[i].id]['arr'] = []
      customDetail[orderList[i].id]['custom_item_config'] = JSON.parse(orderList[i]['custom_item_config'])
      if (main.is_single_tourist) {
        for (const k in contactData[0]) {
          if (contactData[0][k].value[0]['checked']) customDetail[orderList[i].id]['arr'].push(contactData[0][k].value[0])
        }
      } else {
        for (const k in contactData[i]) {
          if (contactData[i][k].value[0]['checked']) customDetail[orderList[i].id]['arr'].push(contactData[i][k].value[0])
          if (contactData[i][k].value[0]['checked'] === false && contactData[i][k].value[0]['name'] === '-' && contactData[i][k].value[0]['phone'] === '13700000000') {
            customDetail[orderList[i].id]['arr'].push(contactData[i][k].value[0])
          }
        }
      }
    }
    const tempSellerId = getTempSellerId(this)
    payData.custom_item_detail = JSON.stringify(customDetail)
    payData.face = contactData[0][0].value[0]['face']
    payData['tempSellerId'] = tempSellerId
    if (status === 6666) {
      const pay = await newHttp.catchPost(GROUP_PAY + orderNo, payData)
      if(pay === "支付成功") {
        that.paySuccess(that.state.paytoken.totalFee);
      }
      return
    }
    if (status === 9999) {
      const info = await http.postCar(CREATE_AND_PAY + fromOrderNum, payData)
      if (info) {
        await payment.payment(info)
        Taro.redirectTo({url: '/main/order/success?pay=' + paytoken.total_fee});
      }
      that.setState({disabled: false})
      return
    }
    if (status == 1) {
      //余额支付
      Taro.showModal({
        title: '提示',
        content: '您确定用余额支付吗?',
        cancelText: '取消',
        confirmText: '确定',
        success: async function (res) {
          if (res.confirm) {
            payData['useAccountPay'] = 1
            const pay = await newHttp.catchPost(GROUP_PAY + orderNo, payData)
            if(pay === "支付成功") {
              that.paySuccess(that.state.paytoken.totalFee);
            }
          }
          that.setState({disabled: false})
        },
        fail: function (red) {
          this.setState({disabled: false})
        }
      })
    } else if (status == 2) {
      // 授信支付
      Taro.showModal({
        title: '提示',
        content: '您确定用授信支付吗?',
        cancelText: '取消',
        confirmText: '确定',
        success: async function (res) {
          if (res.confirm) {
            payData['creditPay'] = 1
            const pay = await newHttp.catchPost(GROUP_PAY + orderNo, payData)
            if(pay === "支付成功") {
              that.paySuccess(that.state.paytoken.totalFee);
            }
          }
          that.setState({disabled: false})
        },
        fail: function (red) {
          this.setState({disabled: false})
        }
      })
    } else if (status == 3) {
      //余额支付
      Taro.showModal({
        title: '提示',
        content: '您确定用蝌蚪币支付吗?',
        cancelText: '取消',
        confirmText: '确定',
        success: async function (res) {
          if (res.confirm) {
            payData['payClass'] = 14
            const pay = await newHttp.catchPost(GROUP_PAY + orderNo, payData)
            if(pay === "支付成功") {
              that.paySuccess(that.state.paytoken.totalFee);
            }
          }
          that.setState({disabled: false})
        },
        fail: function (red) {
          this.setState({disabled: false})
        }
      })
    } else {
      that.payment(orderNo, payData, paytoken)
    }
  }

  async payment(orderNo, payData, paytoken) {
    let api = GROUP_PAY
    if (process.env.TARO_ENV === 'h5') {
      api = H5_ORDER_PAY
      payData['paySource'] = 'gongzhonghao'
    }
    if (this.state.env == 'pc') {
      // const result = await newHttp.put(api + orderNo, payData);
      const pcQrode = await newHttp.catchGet(PC_QRCODE + orderNo, payData)
      this.setState({pcqrcode: pcQrode, pcQrcodeShow: true})
      const time = setInterval(async () => {
        const status = await newHttp.catchGet(PC_ORDER_STATUS + this.state.newPayOrderIdRet.data)
        if (status.isPay) {
          clearInterval(time)
          Taro.redirectTo({url: '/main/order/success?pay=' + this.state.paytoken.totalFee})
        }
      }, 1000)
    } else {
      const pay = await newHttp.catchPost(GROUP_PAY + orderNo, payData)
      if (pay) {
        if (payData['useAccountPay'] == 1 || payData['creditPay'] == 1) {
          Taro.redirectTo({url: '/main/order/success?pay=' + paytoken.totalFee})
        } else {
          const ret = await payment.payment(pay)
          if (ret) {
            Taro.redirectTo({url: '/main/order/success?pay=' + this.state.paytoken.total_fee})
          }
          this.setState({disabled: false})
        }

      }
    }

  }

  // 去充值。
  chongzhi() {
    this.setState({resetBalance: true})
    Taro.navigateTo({
      url: '/distributor/wallet/recharge'
    })
  }

  // 选中联系人
  selectContact(index, idx, num) {
    const {contactData} = this.state
    let arrLen = 0
    for (const i in contactData[index]) {
      if (contactData[index][i]['value'][0]['checked']) arrLen += 1
    }
    if (num !== 1 && arrLen >= num && !contactData[index][idx]['value'][0]['checked']) {
      Taro.showToast({
        title: `此产品仅需添加${num}位出行人信息`,
        icon: 'none',
      })
      return false
    }

    if (num == 1) {
      contactData[index][0]['value'][0]['num'] = 1
      for (const k in contactData[index]) {
        contactData[index][k]['value'][0]['checked'] = false
      }
    }
    contactData[index][idx]['value'][0]['checked'] = !contactData[index][idx]['value'][0]['checked']
    // && num != 1
    if (contactData[index][idx]['value'][0]['checked'] && num != 1) {
      contactData[index][0]['value'][0]['num'] += 1
    } else if (num != 1) {
      contactData[index][0]['value'][0]['num'] -= 1
    }
    if (idx > 2) this.swapArr(contactData, index, idx)
    this.setState({contactData, oldCtIndex: idx, oldFirstIndex: index, index: index})
  }

  swapArr(arr, index1, index2) {
    arr[index1].unshift(arr[index1][index2])
    arr[index1][0]['value'][0]['num'] = arr[index1][1]['value'][0]['num']
    arr[index1].splice(index2 + 1, 1)
    return arr;
  }

  // 联系人删除按钮显示
  showIdcardDel(index, idx) {
    if (this.state.idcardDelIndex != index + '-' + idx) {
      this.state.idcardDelIndex = index + '-' + idx
      this.setState({idcardDelIndex: this.state.idcardDelIndex, idcardDel: this.state.idcardDel})
    } else {
      if (this.state.idcardDelIndex) {
        this.setState({idcardDelIndex: ''})
      } else {
        this.state.idcardDelIndex = index + '-' + idx
        this.setState({idcardDelIndex: this.state.idcardDelIndex, idcardDel: this.state.idcardDel})
      }
    }
  }

  // 删除选中联系人
  delSelectContact(index, idx) {
    const {contactData} = this.state
    contactData[index][idx]['value'][0]['checked'] = false
    contactData[index][0]['value'][0]['num'] -= 1
    this.setState({contactData, idcardDelIndex: ''})
  }

  // 产品数量
  async inputNumber(stock, price, idx, num) {
    const nums = Number(num)
    const stocks = Number(stock)
    const {orderList, orderNo, goodsGroup, contactData} = this.state
    if (nums > stocks) {
    } else {
      if (nums >= 0 && orderList.length > 0 && orderNo && goodsGroup.length > 0) {
        const config = []

        // 无姓名手机号push
        const custom_item_config = JSON.parse(orderList[idx].custom_item_config) // custom_item_config: 游客信息的配置
        for (const k in custom_item_config) {
          if (custom_item_config[k]) config.push(k)
        }
        // 多游客且配置都为空时才会push
        if (orderList[idx].is_custom_item > 0 && config.length === 0) {
          contactData[idx].push(
            {"id":'',
              "uuid":"",
              "value":
                [
                  {"address":"",
                    "comments":"",
                    "city":"",
                    "num":1,
                    "upload_file":"",
                    "face":"",
                    "province":"",
                    "phone":"13700000000",
                    "idcard":"",
                    "name":"-",
                    "checked":true,
                    "region":"",
                    "isInfo":false,
                    "mark":""
                  }
                ],
              "field":"name,phone"
            }
          )
          contactData[idx][0]['value'][0]['num'] = nums
        } else {}

        orderList[idx].num = nums
        // contactData[idx][0]['value'][0]['num'] = nums
        this.setState({orderList: orderList}, () => {
        })
        goodsGroup[idx]['num'] = num
        this.getPaytoken(goodsGroup, idx, false)
      }
    }
  }

  // 联系人姓名电话
  personInput(name, value) {
    const {payData} = this.state
    payData[name] = value
    this.setState({payData})
  }

  // 查看更多
  lookDetail() {
    this.setState({detailShow: !this.state.detailShow})
  }

  ruleChange(e) {
    this.setState({isRule: !this.state.isRule})
  }

  //选择日期
  DayClick(e) {
    if (!this.state.isClickDate) {
      // Taro.showToast({ title: `可以慢一点,不要着急哦~`, icon: 'none',})
      return
    }
    this.getSelectorQuery()
    const day = new Date(e.value).getDay()
    const dateAry = e.value.split('-')
    const {threeDate, week} = this.state
    if (e.value != this.GetDateStr(0) && e.value != this.GetDateStr(1) && e.value != this.GetDateStr(2)) {
      threeDate[2] = {
        showDate: dateAry[1] + '-' + dateAry[2],
        subDate: e.value,
        name: week[day]
      }
    } else {
      const date = new Date(this.GetDateStr(2)).getDay()
      threeDate[2] = {
        showDate: this.GetDateStr(2, false),
        subDate: this.GetDateStr(2),
        name: week[date]
      }
    }
    this.setState({travelDate: e.value, threeDate, floatLayoutCalendar: false}, () => {
      this.getData(e.value, 'date')
    })
  }

  // 切换日期
  changeDate(subDate, status) {
    if (status !== 1) {
      Taro.showToast({title: `已售罄`, icon: 'none',})
      return
    }
    this.getSelectorQuery()
    this.iosScroll()
    this.setState({travelDate: subDate, defaultDate: true}, () => {
      this.getData(subDate, 'date')
    })
  }

  // 获取近三天日期
  getThreeDate() {
    const that = this
    const {orderList} = this.state
    const dayEnd = orderList[0].booking_day_end
    const date: any = []
    let str1: string;
    let str2: string;
    const today = new Date();
    const week = ['周天', '周一', '周二', '周三', '周四', '周五', '周六']
    const dateName = ['今天', '明天']
    for (let i = 0 + dayEnd; i < 3 + dayEnd; i++) {
      str1 = that.GetDateStr(i, false)
      str2 = that.GetDateStr(i)
      const dateArr = str2.split('-')
      date.push({
        showDate: str1,
        subDate: str2,
        name: dayEnd > 0 ? this.oneDay(dateArr[0], dateArr[1], dateArr[2]) : dateName[i]
      })
    }
    const dateArrThree = date[2].subDate.split('-')
    date[2].name = dayEnd > 0 ? this.oneDay(dateArrThree[0], dateArrThree[1], dateArrThree[2]) : week[today.getDay() + 2 >= 7 ? today.getDay() + 2 - 7 : today.getDay() + 2]
    this.setState({threeDate: date, travelDate: this.state.travelDate ? this.state.travelDate : date[0].subDate})
  }

  oneDay(y, m, d) {
    const myDate = new Date();
    myDate.setFullYear(y, m - 1, d);
    const week = myDate.getDay()
    switch (week) {
      case 0:
        return '周日';
      case 1:
        return '周一';
      case 2:
        return '周二';
      case 3:
        return '周三';
      case 4:
        return '周四';
      case 5:
        return '周五';
      case 6:
        return '周六';
    }
  }

  //获取日期
  GetDateStr(AddDayCount, isY = true) {
    const dd = new Date();
    dd.setDate(dd.getDate() + AddDayCount);//获取AddDayCount天后的日期
    const y = dd.getFullYear();
    const m = dd.getMonth() + 1;//获取当前月份的日期
    const d = dd.getDate();
    if (isY) return y + "-" + (m < 10 ? '0' + m : m) + "-" + (d < 10 ? '0' + d : d);
    else return m + "-" + d;
  }

  jump(this, index = this.state.layoutIndex, goodsId = this.state.orderList[this.state.layoutIndex].id, config = this.state.orderList[this.state.layoutIndex].custom_item_config) {
    if (index) {
      this.setState({layoutIndex: index})
    }
    if (this.state.fromGoodDetail) {
      goodsId = this.state.fromGoodDetail.goods_id
      config = this.state.fromGoodDetail.custom_item_config
    }
    Taro.removeStorageSync('addcontact')
    Taro.setStorageSync('addcontact', {
      index: index,
      isCombination: true,
      itemId: this.state.itemId,
      goodsId: goodsId,
      config: config
    })
    Taro.navigateTo({
      url: '/other/address/addcontact'
    })
  }

  openTip(index) {
    const name = '#tips_msg' + index
    const opentips = this.state.opentips
    let oldRectHeight = 0
    const that = this
    this.setState({opentips: !opentips, opentipsIdnex: index}, () => {
      Taro.createSelectorQuery().selectAll(name).boundingClientRect(function (rects) {
        rects.forEach(function (rect, index) {
          rect.height  // 节点的高度
          oldRectHeight = rect.height
          if (that.state.opentips) {
            that.state.itemH += rect.height
          } else {
            that.state.itemH -= that.state.oldRectHeight
          }

        })

      }).exec(() => {
        this.setState({itemH: that.state.itemH, oldRectHeight})
      })
    })

  }

  newAddJump() {
    const {layoutIndex, itemId, orderList} = this.state
    Taro.removeStorageSync('addcontact')
    Taro.setStorageSync('addcontact', {
      index: layoutIndex,
      itemId: itemId,
      isCombination: true,
      goodsId: this.state.orderList[this.state.layoutIndex].id,
      config: orderList[layoutIndex].custom_item_config
    });
    Taro.navigateTo({
      url: '/other/address/addcontact'
    })
  }

  edit(index, idx, goodsId, config, uuid) {
    this.setState({layoutIndex: index, idx})
    Taro.removeStorageSync('addcontact')
    Taro.setStorageSync('addcontact', {
      idx: idx,
      index: index,
      goodsUuid: uuid,
      goodsId: goodsId,
      config: config,
      isCombination: true,
      itemId: this.state.itemId,
      isSave: true
    });
    Taro.navigateTo({
      url: '/other/address/addcontact'
    })
  }

  getSelectorQuery() {
    let itemH = 0
    Taro.createSelectorQuery().selectAll('.ticket_item').boundingClientRect(function (rects) {
      rects.forEach(function (rect, index) {
        rect.height  // 节点的高度
        if (index > 1) return false
        itemH += rect.height
      })

    }).exec(() => {

    })
    Taro.createSelectorQuery().selectAll('.tips_msg').boundingClientRect(function (rects) {
      rects.forEach(function (rect, index) {
        rect.height  // 节点的高度
        if (index > 1) return false
        itemH += rect.height / 2
      })

    }).exec(() => {
      this.setState({itemH})
    })
  }

  async getPhoneNumber(data) {
    try {
      if (data && data.detail && data.detail.errMsg.indexOf('ok') > -1) {
        const res = await http.post(GET_PHONE, {encryptedData: data.detail.encryptedData, iv: data.detail.iv})
        if (res) {
          this.setState({userOk: 1})
          Taro.showToast({title: '授权成功！'})
        } else {
          Taro.showModal({
            title: '提示',
            content: '需要获取手机号，请打开"使用我的用户信息", 然后再点击登录',
            success: (res) => {
              if (res.confirm) {
                Taro.openSetting()
              } else {
                Taro.navigateBack({
                  delta: 1
                })
              }
            }
          })
          console.log('getPhoneNumber: fail')
        }
      } else {
        user.logout()
      }
    } catch (error) {
      console.error(error)
    }
  }

  iosScroll() {
    if (TARO_ENV === 'h5') {
      const u = navigator.userAgent
      const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
      if (isIOS) {
        setTimeout(() => {
          const data = document.querySelector('.footer-btn').offsetTop
          document.getElementsByClassName('footer-btn').cssText = 'position:fixed;bottom:0;left:0'
          document.querySelector('.footer-btn').scrollTo(0, data)
          const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0
          window.scrollTo(0, Math.max(scrollHeight - 1, 0))
        }, 100)
      }
    }
  }

  integralSwitch(value: boolean): void {
    if (this.state.goodDetail) {
      const integral = this.state.goodDetail.integral
      const good = this.state.goodDetail.main
      if (!integral.can) {
        Taro.showToast({title: '当前产品不可使用' + process.env.integralName, icon: 'none'})
        this.setState({useIntegral: false})
        return
      }
      if (good.exchange_type === 2 && integral.score < integral.max) {
        Taro.showToast({title: process.env.integralName + '余额不足', icon: 'none'})
        this.setState({useIntegral: false})
        return
      }
      if (good.exchange_type === 2) {
        let jf: number, useIntegral: boolean;
        ({jf, useIntegral} = this.state);
        if (value) {
          jf = integral.exchangeMaxIntegral
          useIntegral = true
        } else {
          jf = 0
          useIntegral = false
        }
        this.setState({useIntegral: value, jf, useIntegral}, async () => {
          this.getPaytoken()
        })
        this.setState({useIntegral: value})
      } else {
        this.setState({useIntegral: value, indextime: 1}, async () => {
          this.getPaytoken()
        })
        this.setState({useIntegral: value})
      }
    }
  }

  integralSwitchKD(val) {
    const {openKD, payData} = this.state
    if (!openKD) {
      this.setState({openKD: true})
    } else {
      payData['consume_fee'] = 0
      this.setState({openKD: false, payData}, async () => {
        await this.getPaytoken()
      })
    }
  }

  integralChangebtnKD(val) {
    const {payData} = this.state
    Taro.showLoading({title: '计算中...', mask: true})
    payData['consume_fee'] = val.toString().match(/^\d+(?:\.\d{0,2})?/)[0]
    this.setState({payData}, async () => {
      await this.getPaytoken()
    })
  }

  async integralChangebtn(jf) {
    //btn 为1 的时候为用户操作
    const {main} = this.state
    Taro.showLoading({title: '计算中...', mask: true})
    if (main.is_auto_use_integral == 0) {
      this.setState({jf}, async () => {
        await this.getPaytoken()
      })
    }
  }

  async integralChangebtn1(jf) {
    if (jf === this.state.jf) {
      return false
    }
    //btn 为1 的时候为用户操作
    const {main} = this.state
    await Taro.showLoading({title: '计算中...', mask: true})
    main['jf'] = jf
    this.setState({jf}, async () => {
      this.state.jf = jf
      await this.getPaytoken()
    })
  }

  render() {
    const dataColor = Taro.getStorageSync('colorData');
    const {
      openTraveler,
      bottomView,
      commonValidDate,
      openKD,
      paySuccessShow,
      fromOrderNum,
      fromGoodDetail,
      pcQrcodeShow,
      pcqrcode,
      opentips,
      opentipsIdnex,
      calendarInfo,
      fristShow,
      category,
      goodDetail,
      useIntegral,
      isCarry,
      orderDate,
      itemH,
      userBalance,
      showLoading,
      idcardDelIndex,
      userOk,
      platformSet,
      idcardDel,
      isRule,
      layoutIndex,
      disabled,
      payData,
      contactData,
      paytoken,
      threeDate,
      travelDate,
      floatLayout,
      minDate,
      maxDate,
      notice,
      detailShow,
      floatLayoutIdcard,
      floatLayoutCalendar,
      orderList,
      orderListDan,
      main,
      lookMoreShow,
      defaultDate,
      isDaypartingAppointment
    } = this.state
    const _env = this.params.env;
    // @ts-ignore
    return (
      <View className='order-wrap'>
        <GzhAuth />
        <View className='combination-container'>
          <View className='info'>
            <Skeleton title row={2} loading={showLoading}>
              <View className='product_name'>{main.product_name}</View>
              <View className='station'></View>
              {category != 3 && !fromOrderNum && <View className='date'>
                <AtIcon className='dateIcon' prefixClass='car' value='iconshijian' size='14' color='#333' />
                {main.is_valid_today ? '指定入园日期当日可用' : '指定入园有效期内可用'}
              </View>}
            </Skeleton>
            {commonValidDate && category != 3 &&
            <View className='time'><AtIcon customStyle='margin-right:4px' prefixClass='car' value='iconrili' size='12'
              color='#333'
            />{commonValidDate}</View>}
            <Skeleton titleWidth='100%' rowHeight='60px' loading={showLoading}>
              {/*使用日期*/}
              {main.travel_date_style !== 1 && <View>
                <View className='use_date_title'>出行日期</View>
                <View className='use_date_box'>
                  {threeDate && threeDate.map((item, index) =>
                    <View onClick={this.changeDate.bind(this, item.date, item.status)} key={index}
                      style={`background: ${!defaultDate ? '' : travelDate.includes(item.date) && process.env.mainColor};`}
                      className={`user-date-item ${!defaultDate ? '' : travelDate.includes(item.date) && 'active-date'} ${fromGoodDetail ? 'disabled-from' : ''}`}
                    >
                      <View>{item.week_str}</View>
                      <View className='use_showdate'>{item.showDate}
                        <View> {item.status != 1 ? '(售罄)' : ''}</View></View>
                    </View>
                  )}
                  <View onClick={() => {
                    this.setState({floatLayoutCalendar: true})
                  }} className={`user-date-item more_date ${fromGoodDetail ? 'disabled-from' : ''}`}
                  >
                    <View className='lt'>
                      <View>更多</View>
                      <View>日期</View>
                    </View>
                    <View><AtIcon value='chevron-right' size='18' color='#000' /></View>
                  </View>
                </View>
              </View>}
            </Skeleton>
            <Skeleton title row={4} loading={showLoading}>
              <View></View>
            </Skeleton>
            <Skeleton row={4} rowHeight={120} loading={showLoading}>
              <View></View>
            </Skeleton>
            {/*票种*/}
            {orderList.length > 0 && <Skeleton title row={6} loading={showLoading}> <Block>
              <View style={{height: itemH + 'px'}} className={`ticket_box ${lookMoreShow ? 'more_show' : ''}`}>
                {orderList.map((item, index) =>
                  <View id={'the-' + index} className='item ticket_item' key={index}>
                    <View className='title'>
                      <View className='lt'>{item.name}</View>
                      {!fromOrderNum && <View className='rt'>
                        <Text style={`color: ${dataColor.priceColor}`} className='font-family-price icon_ren'>¥</Text>
                        <Text style={`color: ${dataColor.priceColor}`}
                          className='font-family-price price'
                        >{item.price}</Text>
                      </View>}
                    </View>
                    <View className='label'>
                      {item.bookingEndShow && <Text className='label_item'>
                        {item.bookingEndShow}<Text className='separate'>|</Text>
                      </Text>}
                      <View className='buy_notes' onClick={() => {
                        this.setState({notice: item.notice}, () => {
                          this.setState({floatLayout: true})
                        })
                      }}
                      > 购买须知 <AtIcon value='chevron-right' size='14' color='#B6B6B7' /></View>
                    </View>
                    <View className='number'>
                      {!main.is_common_valid_date && <View className='valid_date'>{item.valid_date}</View>}
                      {main.is_common_valid_date && <View> </View>}
                      <View className='input-number'>
                        <NumberInput canZero='true' disabled={fromGoodDetail || isCarry} val={item.num}
                          index={orderDate} step={1} min={0}
                          max={item.surplus_stock}
                          thisChange={this.inputNumber.bind(this, item.surplus_stock, item.price, index)}
                        />
                      </View>
                    </View>
                    {orderList && item.tips_msg && <View id={'tips_msg' + index} className='tips_msg'>
                      {item.tips_msg.length > 0 && item.tips_msg.map((items, i) =>
                        <Block key={i}>
                          {i > 0 && (opentipsIdnex == index && opentips)
                            ?
                            <View className='tips_msg_item'>
                              {items}
                            </View>
                            :
                            <Block>
                              {i == 0 &&
                              <View className='tips_msg_item' key={i} onClick={this.openTip.bind(this, index)}>
                                <AtIcon value='chevron-down' size='8' color='#fff' />
                                {items}
                              </View>}
                            </Block>}
                        </Block>
                      )}
                    </View>}

                  </View>)}
              </View>
            </Block>
            </Skeleton>}
          </View>
          {/*查看更多*/}
          {(orderList.length > 2) &&
          <View onClick={() => (this.setState({lookMoreShow: !this.state.lookMoreShow}))}
            className='ser_more flex_center_center'
          >
            {lookMoreShow ? '收起更多' : '查看更多'}
            {!lookMoreShow && <AtIcon value='chevron-down' size='14' color='#B6B6B7' />}
            {lookMoreShow && <AtIcon value='chevron-up' size='14' color='#B6B6B7' />}
          </View>}
          {orderList.length > 0 && <Skeleton row={4} rowHeight='50px' loading={showLoading}>
            <Block>
              {contactData.length == 0 && <View className='idcard_box_hoder'>
              </View>}
              {openTraveler && paytoken.total_fee != '0.00' && <View className='idcard_box'>
                {main.is_single_tourist && <View className='title'>
                  <Text style='font-weight: 700;'>出行人</Text>
                  {main.is_single_tourist && <Text>仅需添加<Text className='code'>1</Text>位出行人用于接收出票信息</Text>}
                </View>}
                {/*单游客*/}
                {main.is_single_tourist && contactData && contactData.length > 0 && <View>
                  <View className='idCard_label'>
                    {(contactData && contactData.length > 0 && contactData[0] && contactData[0].length > 0) && contactData[0].map((item, idx) =>
                      <Block key={idx}>
                        {idx < 3 && <View onClick={this.selectContact.bind(this, 0, idx, 1)}
                          className={`flex_center_center ${item.value[0].checked ? 'active' : ''} `}
                          style={`border: 1px solid ${process.env.mainColor};color: ${process.env.mainColor}`}
                        >
                          {item.value[0].name}
                          {item.value[0].checked &&
                          <View className='checked' style={`background: ${process.env.mainColor}`}>
                            <AtIcon value='check' size='8' color='#fff' />
                          </View>}
                        </View>}
                      </Block>)}
                    {contactData[0].length <= 3 &&
                    <View onClick={this.jump.bind(this, 0, orderList[0].id, main.single_tourist_config)}
                      className='flex_center_center add' style={`background: ${process.env.mainColor}`}
                    >
                      <AtIcon customStyle='margin-right:4px' value='add-circle' size='14' color='#fff' />
                      添加
                    </View>}
                    {contactData[0].length > 3 &&
                    <View onClick={() => this.setState({floatLayoutIdcard: true, index: 0, layoutIndex: 0})}
                      className='flex_center_center add' style={`background: ${process.env.mainColor}`}
                    >
                      <AtIcon customStyle='margin-right:4px' value='add-circle' size='14' color='#fff' />
                      更多
                    </View>}
                  </View>
                  {(contactData && contactData.length > 0 && contactData[0] && contactData[0].length > 0) && contactData[0].map((list, idx) =>
                    <Block key={idx}>
                      {list.value[0].checked && <View className='idCard_list'>
                        <View className='subtract_circle' onClick={this.showIdcardDel.bind(this, 0, idx)}>
                          <AtIcon value='subtract-circle' size='20' color={`${process.env.mainColor}`}
                            customStyle='vertical-align: inherit;'
                          /></View>
                        <View>
                          <View className='name'>{list.value[0].name}</View>
                          {/*list.value[0].idcard &&*/}
                          {JSON.parse(main.single_tourist_config).idcard &&
                          <View className='idcard'>身份证 {list.value[0].idcard}</View>}
                        </View>
                        <View className='rt-box'>
                          {idcardDel == idx && idcardDelIndex == 0 + '-' + idx &&
                          <View onClick={this.delSelectContact.bind(this, 0, idx, orderList[0].num)}
                            className='del-btn'
                          >删除</View>}
                          {(idcardDel != idx || idcardDelIndex != 0 + '-' + idx) && <View className='chevron_right'
                            onClick={this.edit.bind(this, 0, idx, orderList[0].id, orderList[0].custom_item_config, list.uuid)}
                          >
                            <AtIcon value='chevron-right' size='16' color='#B6B6B7' />
                          </View>}
                        </View>
                      </View>}
                    </Block>)}
                </View>}
                {/*多游客*/}
                {!main.is_single_tourist && contactData.length > 0 && <Block>
                  {orderList.map((item, index) => <Block key={index}> {this.isShowOpenTravel(item) && item.num > 0 && <View>
                    {!main.is_single_tourist && <View className='name_info'>
                      <View>{item.name}</View>
                      <View>添加<Text className='code'>{item.is_custom_item == 0 ? 1 : item.num}</Text>位出行人信息</View>
                    </View>}
                    <View className='idCard_label'>
                      {(contactData && contactData.length > 0 && contactData[index] && contactData[index].length > 0) && contactData[index].map((list, idx) =>
                        <Block key={idx}>
                          {idx < 3 && <View
                            onClick={this.selectContact.bind(this, index, idx, item.is_custom_item == 0 ? 1 : item.num)}
                            className={`flex_center_center ${list.value[0].checked ? 'active' : ''} `}
                          >
                            {list.value[0].name}
                            {list.value[0].checked && <View className='checked'>
                              <AtIcon value='check' size='8' color='#fff' />
                            </View>}
                          </View>}</Block>)}
                      {(contactData && contactData.length > 0 && contactData[index] && contactData[index].length > 0) && contactData[index].length <= 3 &&
                      <View onClick={this.jump.bind(this, index, item.id, item.custom_item_config)}
                        className='flex_center_center add'
                      >
                        <AtIcon customStyle='margin-right:4px' value='add-circle' size='14' color='#fff' />
                        添加
                      </View>}
                      {(contactData && contactData.length > 0 && contactData[index] && contactData[index].length > 0) && contactData[index].length > 3 &&
                      <View onClick={() => this.setState({floatLayoutIdcard: true, layoutIndex: index})}
                        className='flex_center_center add'
                      >
                        <AtIcon customStyle='margin-right:4px' value='add-circle' size='14' color='#fff' />
                        更多
                      </View>}
                      {!(contactData && contactData.length > 0 && contactData[index] && contactData[index].length > 0) &&
                      <View onClick={this.jump.bind(this, index, item.id, item.custom_item_config)}
                        className='flex_center_center add'
                      >
                        <AtIcon customStyle='margin-right:4px' value='add-circle' size='14' color='#fff' />
                        添加
                      </View>}
                    </View>
                    {(contactData && contactData.length > 0 && contactData[index] && contactData[index].length > 0) && contactData[index].map((list, idx) =>
                      <Block key={idx}>
                        {list.value[0].checked && <View className='idCard_list'>
                          <View className='subtract_circle' onClick={this.showIdcardDel.bind(this, index, idx)}>
                            <AtIcon value='subtract-circle' size='20' color='#E68041' /></View>
                          <View>
                            <View className='name'>{list.value[0].name}</View>
                            {list.value[0].idcard && <View className='idcard'>身份证 {list.value[0].idcard}</View>}
                          </View>
                          <View className='rt-box'>
                            {idcardDelIndex == index + '-' + idx &&
                            <View onClick={this.delSelectContact.bind(this, index, idx, item.num)}
                              className='del-btn'
                            >删除</View>}
                            {(idcardDelIndex != index + '-' + idx) && <View className='chevron_right'
                              onClick={this.edit.bind(this, index, idx, item.id, item.custom_item_config, list.uuid)}
                            >
                              <AtIcon value='chevron-right' size='16' color='#B6B6B7' />
                            </View>}
                          </View>
                        </View>}
                      </Block>)}
                  </View>}
                  </Block>)}
                </Block>}
              </View>}
            </Block>
          </Skeleton>}
          {/*联系人*/}
          {openTraveler && (orderList.length > 0) && <View className='contact_box'>
            <View className='title'>
              <View className='font_size_28'>联系人</View>
              <View className='font_size_24'>请添加联系人用于接收出票信息</View>
            </View>
            <AtForm className='person'>
              {!main.is_single_tourist &&
              <AtInput name='linkman' onBlur={this.iosScroll.bind(this)} value={payData.linkman}
                onChange={this.personInput.bind(this, 'linkman')}
                type='text' title='姓名' placeholder='购买人姓名' clear
              />}
              <AtInput name='phone' onBlur={this.iosScroll.bind(this)} value={payData.phone}
                onChange={this.personInput.bind(this, 'phone')} type='text'
                title='手机号码' maxLength={11} placeholder='购买人手机号' clear
              />
            </AtForm>
          </View>}
          {goodDetail.integral && !fromOrderNum && (goodDetail.integral.can) &&
          <View className='integral'>
            <AtSwitch checked={useIntegral} title={`${process.env.integralName}抵扣`} border={false}
              onChange={this.integralSwitch.bind(this)}
              color={`${process.env.mainColor}`}
            />
            {useIntegral && <View className='integral-box'>
              <View className='flex_center_between'>
                <View className='number'>
                  <View className='text'>使用 </View>
                  {(main && main.exchange_type === 2 && main.is_auto_use_integral == 1) &&
                  <View>{main.exchange_type === 2 ? goodDetail.integral.exchangeMaxIntegral : paytoken.jf}</View>}
                  {(main && main.exchange_type === 1 && main.is_auto_use_integral != 1) &&
                  <View>{paytoken.jf}{/*<AtInputNumber type="number" value={paytoken.jf} disabled={main.is_auto_use_integral == 1} max={main && paytoken.maxJf && (paytoken.maxJf <= goodDetail.integral.score ? paytoken.maxJf : goodDetail.integral.score)} onChange={this.integralChangebtn.bind(this)} />*/}</View>}
                  {(main && main.exchange_type === 1 && main.is_auto_use_integral == 1) &&
                  <View>
                    <NumberInput canZero='true' val={paytoken.jf} showMaxToast={false}
                      index={orderDate} step={1} min={0}
                      max={main && paytoken.maxJf && (paytoken.maxJf <= goodDetail.integral.score ? paytoken.maxJf : goodDetail.integral.score)}
                      thisChange={this.integralChangebtn1.bind(this)}
                    />
                  </View>}
                  <View className='text'> {process.env.integralName}抵¥<Text
                    className='price'
                  >{paytoken.integralDeduction}</Text>元</View>
                </View>
                <View className='jian_price'>-¥{paytoken.integralDeduction}</View>
              </View>
              {process.env.P_ENV !== 'kontai' ?
              <View
                className='tips'
              >剩余：{goodDetail && goodDetail.integral.score}{process.env.integralName}，当前商品最大可用{main && main.exchange_max_integral}{process.env.integralName}</View>
              :
              <View
                className='tips'
              >剩余：{goodDetail && goodDetail.integral.score}{process.env.integralName}</View>}
            </View>}
          </View>}
          {/*蝌蚪币*/}
          {process.env.P_ENV === 'kd' &&
          <View className='integral'>
            <AtSwitch checked={openKD} title='蝌蚪币抵扣' border={false}
              onChange={this.integralSwitchKD.bind(this)}
              color={`${process.env.mainColor}`}
            />
            {openKD && <View className='integral-box'>
              <View className='flex_center_between'>
                <View className='number'>
                  <View className='text'>使用</View>
                  <View>
                    <AtInputNumber type='digit'
                      step={1}
                      value={payData.consume_fee.toString().match(/^\d+(?:\.\d{0,2})?/)}
                      min={0.00}
                      max={paytoken.userCoinBalance}
                      onChange={this.integralChangebtnKD.bind(this)}
                    />
                  </View>
                  <View className='text'> 蝌蚪币抵¥<Text
                    className='price'
                  >{payData.consume_fee}</Text>元</View>
                </View>
                <View className='jian_price'>-¥{payData.consume_fee}</View>
              </View>
              <View
                className='tips'
              >当前可用：{paytoken.userCoinBalance}蝌蚪币</View>
            </View>}
          </View>
          }
          {orderList.length > 0 && <View className='agreement'>
            <View><Checkbox value='true' onClick={this.ruleChange.bind(this)} checked={isRule} /></View>
            {process.env.P_ENV !== 'kontai' ? <Block>
              {!!platformSet.platform_terms_of_service_new ? <Block>
                {process.env.TARO_ENV === "weapp" &&
                <parser selectable html={platformSet.platform_terms_of_service_new || ''} />}
                {process.env.TARO_ENV === "tt" &&
                <rich-text preview selectable nodes={getContent(platformSet.platform_terms_of_service_new)} />}
                {process.env.TARO_ENV === "h5" &&
                <View dangerouslySetInnerHTML={{__html: platformSet.platform_terms_of_service_new}} />}
              </Block> : <Block>
                <Text>我已经查看并同意"产品抢购须知"和</Text><Navigator
                  url='/other/agreement/service'
                  className='clause'
                >"{platformSet.platform_terms_of_service}"</Navigator>
              </Block>}
            </Block> : <Block>
              {(category == 3 || category == 2)?
                <Block>
                  { this.siteHash === '950f5513-8b0f-4909-9cc1-75abd92d2737' ? <Block>
                    { category == 3 ? <Text>我已阅读并知晓出行休养行程安排、休养价格、休养服务标准及温馨提醒中的相关内容、预定须知、《职工疗休养服务合同》中的相关内容，并已告知随行人员，视同你单位告知。</Text> :
                      <Text>我已阅读并知晓出行行程安排、行程价格、服务标准以及温馨提醒中的相关内容、《团队境内旅游合同》中的相关内容，并已告知随行人员，视同你单位告知。</Text>
                    }
                  </Block> : <Block>
                    <View>我已阅读并知晓出行行程安排、行程价格、服务标准以及温馨提醒中的相关内容、<Text onClick={()=> { Taro.navigateTo({ url: '/other/agreement/lineService' }) }} className='clause'>《团队境内旅游合同》</Text>中的相关内容，并已告知随行人员，视同你单位告知。</View>
                  </Block>}
                </Block>
                :
                <Block>
                  <View><Text>我已经查看商品购买须知并同意相关</Text></View>
                  <Navigator url='/other/agreement/service' className='clause'>"{platformSet.platform_terms_of_service}"</Navigator>
                </Block>}
            </Block>
            }
          </View>}
        </View>
        {orderList.length > 0 && <View className='footer-btn'>
          <View className='right'>
            {isDaypartingAppointment && (process.env.P_ENV == 'vc' || process.env.P_ENV == 'kunxin') ? <View className='price'></View> : <View className='price'>
              合计：<Text className='text font-family-price'
                style={`color: ${dataColor.priceColor}`}
              >¥{paytoken.total_fee}</Text>
            </View>}
            {paytoken.total_fee != '0.00' && !fromOrderNum && !isDaypartingAppointment &&
            <View onClick={this.lookDetail.bind(this)} className='detail'>明细
              {detailShow && <AtIcon value='chevron-down' size='14' color='#999' />}
              {!detailShow && <AtIcon value='chevron-up' size='14' color='#999' />}
            </View>}
            <Block>
              {userOk == 1 && <Button onClick={this.submitCheck.bind(this)} disabled={disabled} loading={disabled}
                className='btn'
              >{isDaypartingAppointment && (process.env.P_ENV == 'vc' || process.env.P_ENV == 'kunxin') ? '立即预订' : '立即支付'}</Button>}
              {userOk == 2 &&
              <Button className='btn' openType='getPhoneNumber' onGetPhoneNumber={this.getPhoneNumber.bind(this)}
                onError={(err) => {
                        console.log(err)
                      }}
              >{isDaypartingAppointment && (process.env.P_ENV == 'vc' || process.env.P_ENV == 'kunxin') ? '立即预订' : '立即支付'}</Button>
              }
            </Block>
          </View>
          {detailShow &&
          <View onClick={() => {
            this.setState({detailShow: false})
          }} className='price_detail_box'
          >
            <View className='price_detail'>
              <View className='title'>费用明细</View>
              <View className='charge-details-money-wrapper-box'>
                {!!paytoken.goodsPrePrice && <View className='charge-details-money-wrapper'>
                  <View>商品金额</View>
                  <View
                    className='charge-details-money-wrapper-price font-family-price'
                  >￥{paytoken.goodsPrePrice.toFixed(2)}</View>
                </View>}
                {!!paytoken.hbAmount && <View className='charge-details-money-wrapper'>
                  <View>红包</View>
                  <View
                    className='charge-details-money-wrapper-price font-family-price'
                  >￥{paytoken.hbAmount.toFixed(2)}</View>
                </View>}
                {!!paytoken.integralDeduction && <View className='charge-details-money-wrapper'>
                  <View>积分</View>
                  <View
                    className='charge-details-money-wrapper-price font-family-price'
                  >￥{paytoken.integralDeduction.toFixed(2)}</View>
                </View>}
                {!!paytoken.coupon_discount_money && <View className='charge-details-money-wrapper'>
                  <View>优惠券</View>
                  <View
                    className='charge-details-money-wrapper-price font-family-price'
                  >￥{paytoken.coupon_discount_money.toFixed(2)}</View>
                </View>}
                {!!paytoken.goods_discount_code_money && <View className='charge-details-money-wrapper'>
                  <View>推广优惠</View>
                  <View
                    className='charge-details-money-wrapper-price font-family-price'
                  >￥{paytoken.goods_discount_code_money.toFixed(2)}</View>
                </View>}
              </View>
            </View>
          </View>}
        </View>}
        <AtFloatLayout isOpened={floatLayout} title='购买须知' scrollY onClose={() => {
          this.setState({floatLayout: false})
        }}
        >
          {(process.env.TARO_ENV === "weapp" || process.env.TARO_ENV === "tt") ?
            <Block>
              <View className='float-layout'>
                <parser html={notice || ''} />
              </View>
            </Block>
            :
            <Block>
              {!!notice && <View dangerouslySetInnerHTML={{__html: notice}} className='float-layout' />}
            </Block>}
        </AtFloatLayout>
        <AtFloatLayout className='layout_idcard' isOpened={floatLayoutIdcard} scrollY={false}>
          <View className='flex_center_between operating'>
            <View onClick={() => this.setState({floatLayoutIdcard: false})}>取消</View>
            <View onClick={() => this.setState({floatLayoutIdcard: false})}>确定</View>
          </View>
          <View onClick={this.newAddJump.bind(this)} className='flex_center_center add-box'>
            <AtIcon value='add-circle' size='22' color='#EDAF2E' />
            <Text>新增</Text>
          </View>
          <ScrollView scrollTop={0} scrollY scrollIntoView={`${bottomView}`} className='layout_idcard_item_box'>
            {contactData && contactData.length > 0 && contactData[layoutIndex].map((list, idx) =>
              <View
                id={`bottomView${idx}`}
                onClick={this.selectContact.bind(this, layoutIndex, idx, orderList[layoutIndex].is_custom_item == 0 ? 1 : orderList[layoutIndex].num)}
                key={idx} className='layout_idcard_item'
              >
                <View
                  onClick={this.edit.bind(this, layoutIndex, idx, orderList[layoutIndex].id, orderList[layoutIndex].custom_item_config, list.uuid)}
                >
                  <AtIcon prefixClass='car' value='iconbianji' size='18' color='#999' /></View>
                <View className='info'>
                  <View className='view1'> {list.value[0].name}</View>
                  {list.value[0].idcard && <View className='view2'>身份证 {list.value[0].idcard}</View>}
                  {list.value[0].phone && <View className='view3'>手机号 {list.value[0].phone}</View>}
                </View>
                <View>
                  {list.value[0].checked && <View className='idcard_checked'>
                    <Image mode='widthFix' style='width: 32px;heigth:32px'
                      src='https://resource.ivcheng.com/resources/weapp/images/xuan.png'
                    />
                  </View>}
                  {!list.value[0].checked && <View className='idcard_checked_no'>

                  </View>}
                </View>
              </View>)}
          </ScrollView>
        </AtFloatLayout>
        {!showLoading && orderList.length == 0 && <View className='listNull'>
          <Image src={`${RESOURCE_URL}/resources/images/shopnull.png`} mode='widthFix'></Image>
          <View className='text1'>亲，暂无符合您需要的商品~</View>
          <View className='text2'>请切换日期、票种等选项看看其他商品</View>
        </View>}
        {paytoken && <AtModal onClose={this.handleClose.bind(this)} isOpened={userBalance}>
          <AtModalContent>
            <View className='modal-box'>
              <View className='modal-title'>选择支付方式</View>
              {/*{process.env.P_ENV === 'kd' && <Block>
                {paytoken.userCoinBalance >= paytoken.totalFee ?
                  <View className="modal-item" onClick={this.groupPay.bind(this, 3)}><Image
                    src={RESOURCE_URL + "/upload/images/20220130/1643551597986_748.png"}/>蝌蚪币支付（剩余￥{paytoken.userCoinBalance}）<View
                    className="right"><AtIcon
                    value='chevron-right' size='15' color='#c9c9c9'/></View></View> :
                  <View className="modal-item disabled"><Image
                    src={RESOURCE_URL + "/upload/images/20220130/1643551597986_748.png"}/>蝌蚪币支付（剩余￥{paytoken.userCoinBalance}）<View
                    className="right"><AtIcon
                    value='chevron-right' size='15' color='#c9c9c9'/></View></View>}
              </Block>}*/}
              <View className='modal-item' onClick={this.groupPay.bind(this, 0)}><Image
                src={RESOURCE_URL + "/resources/weapp/images/wxico.png"}
              />微信支付 <View className='right'><AtIcon
                value='chevron-right' size='15' color='#c9c9c9'
              /></View></View>


              <View className='close-modal' onClick={() => (this.setState({userBalance: false}))}><AtIcon value='close'
                size='15'
                color='#333'
              /></View>
              {process.env.P_ENV !== 'lx' && <Block>
                {paytoken.userBalance > paytoken.total_fee ?
                  <View className='modal-item' onClick={this.groupPay.bind(this, 1)}><Image
                    src={RESOURCE_URL + "/resources/weapp/images/yeico.png"}
                  />余额（剩余￥{paytoken.userBalance}） <View
                    className='right'
                  ><AtIcon value='chevron-right' size='15' color='#c9c9c9' /></View></View>
                  :
                  <View className='modal-item disabled'><Image
                    src={RESOURCE_URL + "/resources/weapp/images/yeico.png"}
                  /><View className='czbox'><View
                    className='cztext'
                  >余额（剩余￥{paytoken.userBalance}）</View><View
                    className='cztext'
                  >余额不足</View></View>
                    {_env != 'pc' && <View className='right' onClick={this.chongzhi.bind(this)}>去充值</View>}
                  </View>
                }
              </Block>}

              {!!paytoken.isOpenCredit && !useIntegral && !openKD &&
              <Block>
                {(Number(paytoken.creditAmount) || 0) >= Number(paytoken.total_fee) ?
                  <View className='modal-item' onClick={this.groupPay.bind(this, 2)}><Image
                    src={RESOURCE_URL + "/resources/weapp/images/xinicon.png"}
                  />授信支付<View
                    className='right'
                  ><AtIcon
                    value='chevron-right' size='15' color='#c9c9c9'
                  /></View></View>
                  :
                  <View className='modal-item disabled'><Image
                    src={RESOURCE_URL + "/resources/weapp/images/xinicon.png"}
                  />授信支付<View
                    className='right'
                  ><AtIcon
                    value='chevron-right' size='15' color='#c9c9c9'
                  /></View></View>
                }
              </Block>
              }
            </View>
          </AtModalContent>
        </AtModal>}
        {pcQrcodeShow && <View className='curtainRoot'>
          <View className='pc-root'>
            <Image className='pcqrcode' src={pcqrcode} mode='widthFix' />
            <View className='pc-tips'>请用微信扫码支付</View>
            <View onClick={() => {
              this.setState({pcQrcodeShow: false, submiting: false})
            }} className='gzh-close'
            >
              <AtIcon value='close' color='#000' />
            </View>
          </View>
        </View>}
        {floatLayoutCalendar && <Calendar env={_env} fristShow={fristShow} onClose={() => {
          this.setState({floatLayoutCalendar: false})
        }} data={calendarInfo} mode='callback' type={goodDetail.main.category === 2 ? 'range' : 'single'}
          day_end={goodDetail.goodsList.booking_day_end}
          time_end={goodDetail.goodsList.booking_time_end}
          category={category} isGroup single={travelDate}
          onConfirm={this.calendarSelect.bind(this)}
        />}
        <AtModal isOpened={paySuccessShow} closeOnClickOverlay={false}>
          {paySuccessShow && <View>
            <View className='pc-root'>
              <Icon size='60' type='success' />
              <View style='color: #333; font-size: 18px; margin-top: 20px;'>支付成功</View>
            </View>
          </View>}
        </AtModal>
      </View>
    );
  }
}

export default Combination as ComponentClass<PageOwnProps, PageState>
